<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <title>amis demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="./assets/amis-sdk/sdk.css" />
    <link rel="stylesheet" href="./assets/amis-sdk/helper.css" />
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
      html,
      body,
      .app-wrapper {
        position: relative;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="root" class="app-wrapper"></div>
	<button onclick="test()">点击调试-获取值</button>
	<button onclick="test2()">点击调试-設置值</button>
	<button onclick="setVal2()">点击调试-設置值-222</button>
    <script src="./assets/amis-sdk/sdk.js"></script>
	<script src="./assets/amis-json/amis_test_js_function.json?callback=get_amis_test_js_function_Json"></script>
    <script type="text/javascript">
	
	
	var amis=null;
	var amisScoped=null;
	
	  (function () {
         amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
          get_amis_test_js_function_Json();
      })();
	  
	  function get_amis_test_js_function_Json(data) {
          // data 就是要取的json数据
          console.log(data);
		   amisScoped = amis.embed('#root', data);
        }

	  

	  function getVal3(){

	    let compInstance1=amisScoped.getComponentByName("page1")
		let data=compInstance1.props.data
		 let name1_value=compInstance1.props.data.username
		 console.log("getVal3 data="+JSON.stringify(data))
		 console.log("getVal3 username_value="+JSON.stringify(name1_value))
	  }	 
	  
	  function setVal1(){		 
		 amisScoped.updateProps(
					  {
						data:{"username":"通过amisScoped.updateProps 设置值"}
					  } 
					);
	  }	 

	  function setVal2(){		 
		 amisScoped.updateProps(
					  {
						data:{"username":"通过amisScoped.updateProps 设置值-2222"}
					  } 
					);
	  }	 
     function test(){
	   getVal3();
      }	 
	  
	  function test2(){
	    setVal1();
	  }
	  
	 function  test_amis_call_js_function(){
	   		 amisScoped.updateProps(
					  {
						data:{"username":"test_amis_call_js_function 测试 通过amisScoped.updateProps 设置值"}
					  } 
					);   
	 }
	 
    </script>
  </body>
</html>